package com.chenglu.android.orderinfo.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.orderinfo.bean.OrderDetailBean;


import java.util.List;


/**
 * @author: lyj
 * @Created: by Copyright 2023/3/29 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：订单详情布局
 */
public class OrderInfoAdapter extends BaseQuickAdapter<OrderDetailBean.Data.OrderDetails, BaseViewHolder> {

    Context mContext;

    public OrderInfoAdapter(Context context, int layoutResId, List<OrderDetailBean.Data.OrderDetails> data) {
        super(layoutResId, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderDetailBean.Data.OrderDetails item) {

        helper.setText(R.id.tv_cart_goodsName, item.getGoodsVO().getGoodsName());
        ImageView imageView = helper.getView(R.id.iv_cart_goodsImg);

        GlideUtils.setImageView(mContext,item.getGoodsVO().getGoodsImg(),imageView,8);
        TextView tvGoodsNumber = helper.getView(R.id.tv_goods_number);
        tvGoodsNumber.setText("X"+item.getGoodsAmount());

        if(item.getGoodsVO().getGoodsSkus().isEmpty()){
            helper.setText(R.id.tv_cart_goodsTotalPrice,Utils.formatZeroNumber(item.getGoodsVO().getGoodsPrice()));
        }else {
            helper.setText(R.id.tv_cart_goodsTotalPrice,Utils.formatZeroNumber(item.getGoodsVO().getGoodsSkus().get(0).getGoodsPrice()));
        }



    }

}
